from abc import ABC, abstractmethod
from pathlib import Path
from typing import Dict, List, Union
import numpy as np

class BaseCoinDatabase(ABC):
    """硬币数据库的抽象基类"""
    
    @abstractmethod
    def add_coin(self, coin_id: str, front_features: np.ndarray, back_features: np.ndarray,
                front_path: Path, back_path: Path, annotations: dict = None):
        """添加硬币到数据库"""
        pass

    @abstractmethod
    def find_similar_coins(self, query_front_features: np.ndarray, query_back_features: np.ndarray,
                        top_k: int = 5) -> List[Dict[str, Union[str, float, dict]]]:
        """查找相似硬币"""
        pass

    @abstractmethod
    def save_to_file(self, file_path: str):
        """保存数据库到文件"""
        pass

    @abstractmethod
    def load_from_file(self, file_path: str):
        """从文件加载数据库"""
        pass 